﻿<Grid Padding="10" RowDefinitions="Auto, Auto" ColumnDefinitions="Auto, *">
    <TapGestureRecognizer OnTapped="Details" />
    <GridCell RowSpan="2">
        <Image Source="imageSource"
               Aspect="Aspect.AspectFill"
               HeightRequest="60"
               WidthRequest="60" />
    </GridCell>

    <GridCell Column="1">
        <Label Text="@Animal.Name"
               FontAttributes="FontAttributes.Bold" />
    </GridCell>

    <GridCell Row="1" Column="1">
        <Label Text="@Animal.Location"
               FontAttributes="FontAttributes.Italic"
               VerticalOptions="LayoutOptions.End" />
    </GridCell>
</Grid>


@code
{
    [Parameter] public Animal Animal { get; set; }
    [Parameter] public EventCallback<Animal> OnClick { get; set; }

    UriImageSource imageSource = new UriImageSource();

    protected override void OnParametersSet()
    {
        var uri = new Uri(Animal.ImageUrl);
        imageSource.Uri = uri;
    }

    void Details()
    {
        if (OnClick.HasDelegate)
            OnClick.InvokeAsync(Animal);
    }
}
